<?php
/**
 * ============================================================================
 * 版权所有 2008-2011 多多网络，并保留所有权利。
 * 网站地址: http://soft.duoduo123.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
session_start();
error_reporting(0);
include_once 'comm/config.php';
include_once 'comm/Taoapi.php';
include_once 'comm/page.class.php';
include_once 'comm/checkpostandget.php';

$cid=$_GET['cid'];
$start_level=$_GET['start_level'];
$end_level=$_GET['end_level'];
$keyword=trim($_GET['keyword']);

$area=$_GET['area'];
$cpr=$_GET['cpr'];
$type=$_GET['type'];
$px=$_GET['px'];
$subsql='1=1';

if($cid!=''){
	$arrcid=preg_split("/[,]/", $cid);
	$subsql="(";
	for($i=0;$i<count($arrcid);$i++)
	{
		if($i==(count($arrcid)-1)){
			$subsql=$subsql." cid='".$arrcid[$i]."'";
		}else{
			$subsql=$subsql." cid='".$arrcid[$i]."' or ";
		}
	}
	$subsql=$subsql.")";
}

if($start_level!=''&&$end_level=='')
{
	$startlevel=$start_level;
	$endlevel=20;
}elseif($start_level==''&&$end_level!='')
{
	$startlevel=1;
	$endlevel=$end_level;
}
else
{
	$startlevel=$start_level;
	$endlevel=$end_level;
}
if($startlevel>$endlevel)
{
	$temp=$startlevel;
	$startlevel=$endlevel;
	$endlevel=$temp;
}

if($startlevel!='')
{
	$subsql=$subsql." and level>=".$startlevel."";
}
if($endlevel!='')
{
	$subsql=$subsql." and level<=".$endlevel."";
}
if($keyword!='请输入店铺或掌柜名称...'&&$keyword!='')
{
	$subsql=$subsql." and (nick like '%".$keyword."%' or title like '%".$keyword."%')";
}
else{
    $keyword='';
}
if($area!=''){
	$sql_area=str_replace(',','\',\'',$area);
	$subsql=$subsql." and (city in ('".$sql_area."') or state in ('".$sql_area."'))";
}
//if($cpr=='1')
//{
//	$subsql=$subsql." and consumer_protection='true'";
//}
if($type=='1')
{
	$subsql=$subsql." and `type`='B'";
}
if($px=='1'){
	$subsql=$subsql." order by level desc";
}
if($px=='0'){
	$subsql=$subsql." order by level asc";
}
if($px==''){
	$subsql=$subsql." order by tuijian desc,addtime desc";
}
$page = !($_GET['page'])?'1':intval($_GET['page']);
$pagesize=20;
$frmnum=($page-1)*$pagesize;

$sql="select count(*) as totalnum from ".$BIAOTOU."shop where ".$subsql;
$rsnum = mysql_query($sql);
$rownum = mysql_fetch_array($rsnum);
$total=$rownum["totalnum"];

$sql="select * from ".$BIAOTOU."shop where ".$subsql." limit $frmnum,$pagesize";
$rs=mysql_query($sql);

$tag="shoplist";
include_once 'comm/wjt.php';
//引入模版文件
include 'template/'.MOBAN.'/shoplist.tpl.php';
mysql_close($cfg_link);
?>